prometheus-node-exporter-lua: add HTTPS support
authorEtienne Champetier <[email protected]>
Mon, 23 Jun 2025 14:19:03 +0000 (10:19 -0400)
committerEtienne Champetier <[email protected]>
Mon, 23 Jun 2025 17:53:38 +0000 (20:53 +0300)
With valid 'cert'/'key' config, prometheus-node-exporter-lua
will respond to https instead of http on 'listen_port'.

Signed-off-by: Etienne Champetier <[email protected]>
utils/prometheus-node-exporter-lua/Makefile
utils/prometheus-node-exporter-lua/files/etc/config/prometheus-node-exporter-lua
utils/prometheus-node-exporter-lua/files/etc/init.d/prometheus-node-exporter-lua

index edd3bd083a519a50c332c3e608c1ee9546efe1c3..ce0964b3a6e02f9e9c68589223abfdfb8bdb50ba 100644 (file)
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=prometheus-node-exporter-lua
 PKG_VERSION:=2025.06.23
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 
 PKG_MAINTAINER:=Etienne CHAMPETIER <[email protected]>
 PKG_LICENSE:=Apache-2.0
index d424fe6322c66436720d1b7a2fdc9eed1ffd9814..85f3cd720a28dd218b48c31c94ad08b64231dfa8 100644 (file)
@@ -1,3 +1,5 @@
 config prometheus-node-exporter-lua 'main'
        option listen_interface 'loopback'
        option listen_port '9100'
+       #option cert '/etc/uhttpd.crt'
+       #option key '/etc/uhttpd.key'
index 7dc8bc199c7f93ea24a7f337f19f26f31bbfc456..154ce13539f9a65cb2407643c3615d9c11ecb5fa 100644 (file)
@@ -11,12 +11,14 @@ _log() {
 start_service() {
        . /lib/functions/network.sh
 
-       local interface port bind4 bind6
+       local interface port listenflag cert key bind4 bind6
 
        config_load prometheus-node-exporter-lua.main
        config_get keepalive "main" http_keepalive 70
        config_get interface "main" listen_interface "loopback"
        config_get port "main" listen_port 9100
+       config_get cert "main" cert
+       config_get key "main" key
 
        [ "$interface" = "*" ] || {
                network_get_ipaddr  bind4 "$interface"
@@ -25,18 +27,25 @@ start_service() {
                        _log "defering start until listen interface $interface becomes ready"
                        return 0
                }
-    }
+       }
 
        procd_open_instance
 
        procd_set_param command /usr/sbin/uhttpd -f -c /dev/null -l / -L /usr/bin/prometheus-node-exporter-lua
        [ $keepalive -gt 0 ] && procd_append_param command -k $keepalive
 
+       if [ -f "$cert" -a -f "$key" ]; then
+               listenflag=-s
+               procd_append_param command -C $cert -K $key
+       else
+               listenflag=-p
+       fi
+
        if [ "$interface" = "*" ]; then
-               procd_append_param command -p $port
+               procd_append_param command $listenflag $port
        else
-               [ -n "$bind4" ] && procd_append_param command -p $bind4:$port
-               [ -n "$bind6" ] && procd_append_param command -p [$bind6]:$port
+               [ -n "$bind4" ] && procd_append_param command $listenflag $bind4:$port
+               [ -n "$bind6" ] && procd_append_param command $listenflag [$bind6]:$port
        fi
 
        procd_set_param stdout 1